<!--
 * @Author: haoshenpei
 * @Date: 2025-02-24 17:23:12
 * @LastEditors: hyman
 * @LastEditTime: 2025-02-26 14:08:05
 * @Description: 请填写简介
-->
<template>
    <div>
        <a-modal
      title="Title"
      :visible="visible"
      :confirm-loading="confirmLoading"
      @ok="handleOk"
      @cancel="handleCancel"

    >
        <!-- :destroyOnClose="destroyOnClose"<a-form-model ref="formRef" :preserve-form="false">
            <list :list="list" :model="model" @change="changeF" />
        </a-form-model> -->
        <list v-if="visible" :list="list" :model="model" @change="changeF" ref="list" />

    </a-modal>
    </div>
</template>

<script>
    import list from './list'
    export default {
        components:{
            list
        },
        props:{
            list:{
                type:Array,
                default:()=>{
                    return []
                }
            },
            model:{
                type:Object,
                default:()=>{
                    return {}
                }
            }
        },
        data(){
            return {
                destroyOnClose:true,
                ModalText: 'Content of the modal',
                visible: false,
                confirmLoading: false,
            }
        },
        beforeDestroy() {
            console.log('modal-destroyOnClose')
           //this.destroyOnClose = true
           //this.$refs.list && this.$refs.list.$destroy();
           //this.$refs.list = null
        },
        methods:{
            clearF(){
                this.$refs.formRef.resetFields();
            },
            showModal() {
                this.visible = true;
            },
            handleOk(e) {
                this.ModalText = 'The modal will be closed after two seconds';
                this.confirmLoading = true;
                setTimeout(() => {
                    this.visible = false;
                    this.confirmLoading = false;
                }, 2000);
            },
            handleCancel(e) {
                console.log('Clicked cancel button');
                this.visible = false;
            },
            changeF(data){
                this.$emit('change',data)
            },
        }
    }
</script>

<style  scoped>
.modal-container {
    position: relative; /* 确保模态框定位正确 */
}
</style>
